package br.com.blsystems.sistemavendas;

import org.hibernate.SessionFactory;
import org.hibernate.cfg.Configuration;

public class HibernateUtil {
	
	/*Esse Metodo vai retornar a sessão do banco pra mim (~ buildSessionFactory ~)*/
	private static final SessionFactory sessao = trazerSessao();

	
	private static SessionFactory trazerSessao() {
		
		try {
			Configuration configuracao = new Configuration();
			configuracao.configure("hibernate.cfg.xml");
			return configuracao.buildSessionFactory();
		} 
		
		catch (Throwable e) {
			System.out.println("Erro na Conexao!!!" + e);
			throw new ExceptionInInitializerError();
			
		}
	}

	public static SessionFactory getSessao() {
		return sessao;
	}
	

}
